<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box" style="width: 200px; height: 200px; background-color: red; position: relative;"></div>
    <script>
        var box = document.getElementById("box");
        box.addEventListener("mousemove", function(event) {
            var x = event.clientX - box.offsetLeft;
                var y = event.clientY - box.offsetTop;
            console.log("鼠标在盒子内的坐标为：" + x + "," + y);
                });
                box.addEventListener("mouseout", function() {
                            console.log("鼠标移出盒子");
                            });
                         
    </script>
</body>
</html>